package com.iplant.wms.service.po.asn;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.iplant.base.po.BasePO;
import com.iplant.base.po.enums.DBSchemas;
import com.iplant.base.utils.annotation.field.DBField;
import com.iplant.base.utils.annotation.condition.DBCondition;
import com.iplant.base.utils.annotation.join.DBJoin;
import com.iplant.base.utils.annotation.join.multi.select.DBJoinMultiSelect;
import com.iplant.base.utils.annotation.po.DBBasePO;
import com.iplant.base.utils.general.CalendarTool;
import com.iplant.wms.service.basicenum.asn.WMSReceiveStatus;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

/**
 * 收货单
 */
@DBBasePO(TableName = "wms_receivebill", Name = false, Active = false, Schemas = DBSchemas.WMS,
        CheckName = {"Code"}, CodeAuto = true, CodePrefix = "RCVB{yyMM}-")
public class WMSReceiveBill extends BasePO implements Serializable {

    /**
     * 序列化
     */
    private static final long serialVersionUID = 1L;


    @DBCondition
    @DBField(Update = false)
    public int FactoryID = 0;

    @DBJoin(name = "Code", tableName = "fmc_factory", tableAsName = "f1",
            Schemas = DBSchemas.Basic, MainTableField = "FactoryID")
    public String FactoryCode = "";

    @DBJoin(name = "Name", tableName = "fmc_factory", tableAsName = "f1",
            Schemas = DBSchemas.Basic, MainTableField = "FactoryID")
    public String FactoryName = "";

    /**
     * 关联的U8主单据ID（U8采购到货单ID）
     */
    @DBField
    public int U8BillID = 0;
    /**
     * 关联的U8主单据编号（U8采购到货单编号）
     */
    @DBField
    public String U8BillCode = "";

    /**
     * 采购订单
     */
    @DBCondition
    @DBField
    public int PurchaseOrderID = 0;

    /**
     * 采购订单
     */
    @DBCondition(CompareType = DBCondition.DBCompareType.like, ParamName2 = "PurchaseOrderCodeEQ")
    @DBField
    public String PurchaseOrderCode = "";


    /**
     * 从到货通知单创建收货单时记录到货通知单号
     */
    @DBCondition
    @DBField
    public int ArrivalNoticeID = 0;

    @DBCondition
    @DBField
    public String ArrivalNoticeCode = "";
    /**
     * 到货日期
     */
    @DBCondition(CompareType = DBCondition.DBCompareType.geLe,
            ParamName = "ArrivalDateStart", ParamName2 = "ArrivalDateEnd")
    @DBField
    public Calendar ArrivalDate = CalendarTool.getBasicDate();

    /**
     * WMSReceiveType 收货单类型，0-默认，1-直接收货，2-通知单收货，3-采购收货，4-生产收货
     * 换U8数据源后此值无效
     */
    @DBField
    public int TypeID = 0;
    @DBJoin(name = "Name", tableName = "wms_bill_type", Schemas = DBSchemas.WMS, tableAsName = "bt1", MainTableField = "TypeID")
    public String TypeName = "";

    @DBJoin(name = "Code", tableName = "wms_bill_type", Schemas = DBSchemas.WMS, tableAsName = "bt1", MainTableField = "TypeID")
    public String TypeCode = "";

    /**
     * 货主 就是客户
     */
    @DBCondition
    @DBField
    public int CustomerID = 0;

    @DBCondition(CompareType = DBCondition.DBCompareType.like)
    @DBJoin(name = "Code", tableName = "crm_customer", tableAsName = "c1",
            Schemas = DBSchemas.Basic, MainTableField = "CustomerID")
    public String CustomerCode = "";

    @DBCondition(CompareType = DBCondition.DBCompareType.like)
    @DBJoin(name = "Name", tableName = "crm_customer", tableAsName = "c1",
            Schemas = DBSchemas.Basic, MainTableField = "CustomerID")
    public String CustomerName = "";

    /**
     * 供应商
     */
    @DBCondition
    @DBField
    public int SupplierID = 0;
    @DBCondition(CompareType = DBCondition.DBCompareType.like)
    @DBJoin(name = "Code", tableName = "crm_customer", tableAsName = "c2",
            Schemas = DBSchemas.Basic, MainTableField = "SupplierID")
    public String SupplierCode = "";

    @DBCondition(CompareType = DBCondition.DBCompareType.like)
    @DBJoin(name = "Name", tableName = "crm_customer", tableAsName = "c2",
            Schemas = DBSchemas.Basic, MainTableField = "SupplierID")
    public String SupplierName = "";


    @DBCondition
    @DBField
    public Integer ReceiverID = 0;

    @DBJoin(name = "Name", tableName = "mbs_user", tableAsName = "u3", Schemas = DBSchemas.Basic, MainTableField =
            "ReceiverID")
    public String ReceiverName = "";

    @DBCondition(CompareType = DBCondition.DBCompareType.geLe, ParamName = "ReceivedTimeStart", ParamName2 = "ReceivedTimeEnd")
    @DBField
    public Calendar ReceivedTime = CalendarTool.getBasicDate();

    @DBField
    public List<String> ImageList = new ArrayList<>();

    @DBCondition
    @DBField
    public String ProjectNo = "";

    @DBCondition(CompareType = DBCondition.DBCompareType.in)
    @DBField
    public int Status = 0;

    public String StatusText = "";

    @DBJoinMultiSelect(OutTableField = "ReceiveBillID", ItemClazz = WMSReceiveBillItem.class)
    public List<WMSReceiveBillItem> ItemList = new ArrayList<>();

    public WMSReceiveBill() {
        super();
    }

    @JsonProperty("ArrivalNoticeCode")
    public String getArrivalNoticeCode() {
        return ArrivalNoticeCode;
    }

    public void setArrivalNoticeCode(String arrivalNoticeCode) {
        ArrivalNoticeCode = arrivalNoticeCode;
    }


    @JsonProperty("TypeID")
    public int getTypeID() {
        return TypeID;
    }

    public void setTypeID(int typeID) {
        TypeID = typeID;
    }

    @JsonProperty("TypeName")
    public String getTypeName() {
        return TypeName;
    }

    public void setTypeName(String typeName) {
        TypeName = typeName;
    }

    @JsonProperty("TypeCode")
    public String getTypeCode() {
        return TypeCode;
    }

    public void setTypeCode(String typeCode) {
        TypeCode = typeCode;
    }

    @JsonProperty("CustomerID")
    public int getCustomerID() {
        return CustomerID;
    }

    public void setCustomerID(int customerID) {
        CustomerID = customerID;
    }

    @JsonProperty("CustomerName")
    public String getCustomerName() {
        return CustomerName;
    }

    public void setCustomerName(String customerName) {
        CustomerName = customerName;
    }

    @JsonProperty("CustomerCode")
    public String getCustomerCode() {
        return CustomerCode;
    }

    public void setCustomerCode(String customerCode) {
        CustomerCode = customerCode;
    }

    @JsonProperty("SupplierID")
    public int getSupplierID() {
        return SupplierID;
    }

    public void setSupplierID(int supplierID) {
        SupplierID = supplierID;
    }

    @JsonProperty("SupplierCode")
    public String getSupplierCode() {
        return SupplierCode;
    }

    public void setSupplierCode(String supplierCode) {
        SupplierCode = supplierCode;
    }

    @JsonProperty("SupplierName")
    public String getSupplierName() {
        return SupplierName;
    }

    public void setSupplierName(String supplierName) {
        SupplierName = supplierName;
    }

    @JsonProperty("ReceiverID")
    public Integer getReceiverID() {
        return ReceiverID;
    }

    public void setReceiverID(Integer receiverID) {
        ReceiverID = receiverID;
    }

    @JsonProperty("ReceiverName")
    public String getReceiverName() {
        return ReceiverName;
    }

    public void setReceiverName(String receiverName) {
        ReceiverName = receiverName;
    }

    @JsonProperty("ReceivedTime")
    public Calendar getReceivedTime() {
        return ReceivedTime;
    }

    public void setReceivedTime(Calendar receivedTime) {
        ReceivedTime = receivedTime;
    }

    @JsonProperty("ProjectNo")
    public String getProjectNo() {
        return ProjectNo;
    }

    public void setProjectNo(String projectNo) {
        ProjectNo = projectNo;
    }

    @JsonProperty("ItemList")
    public List<WMSReceiveBillItem> getItemList() {
        return ItemList;
    }

    public void setItemList(List<WMSReceiveBillItem> itemList) {
        ItemList = itemList;
    }


    @JsonProperty("ArrivalDate")
    public Calendar getArrivalDate() {
        return ArrivalDate;
    }

    public void setArrivalDate(Calendar arrivalDate) {
        ArrivalDate = arrivalDate;
    }


    @JsonProperty("U8BillID")
    public int getU8BillID() {
        return U8BillID;
    }

    public void setU8BillID(int u8BillID) {
        U8BillID = u8BillID;
    }

    @JsonProperty("U8BillCode")
    public String getU8BillCode() {
        return U8BillCode;
    }

    public void setU8BillCode(String u8BillCode) {
        U8BillCode = u8BillCode;
    }

    @JsonProperty("FactoryID")
    public int getFactoryID() {
        return FactoryID;
    }

    public void setFactoryID(int factoryID) {
        FactoryID = factoryID;
    }

    @JsonProperty("FactoryCode")
    public String getFactoryCode() {
        return FactoryCode;
    }

    public void setFactoryCode(String factoryCode) {
        FactoryCode = factoryCode;
    }

    @JsonProperty("FactoryName")
    public String getFactoryName() {
        return FactoryName;
    }

    public void setFactoryName(String factoryName) {
        FactoryName = factoryName;
    }

    @JsonProperty("ArrivalNoticeID")
    public int getArrivalNoticeID() {
        return ArrivalNoticeID;
    }

    public void setArrivalNoticeID(int arrivalNoticeID) {
        ArrivalNoticeID = arrivalNoticeID;
    }

    @JsonProperty("Status")
    public int getStatus() {
        return Status;
    }

    public void setStatus(int status) {
        Status = status;
    }

    @JsonProperty("StatusText")
    public String getStatusText() {
        StatusText = WMSReceiveStatus.getEnumType(Status).getLabel();
        return StatusText;
    }

    public void setStatusText(String statusText) {
        StatusText = statusText;
    }

    @JsonProperty("PurchaseOrderID")
    public int getPurchaseOrderID() {
        return PurchaseOrderID;
    }

    public void setPurchaseOrderID(int purchaseOrderID) {
        PurchaseOrderID = purchaseOrderID;
    }

    @JsonProperty("PurchaseOrderCode")
    public String getPurchaseOrderCode() {
        return PurchaseOrderCode;
    }

    public void setPurchaseOrderCode(String purchaseOrderCode) {
        PurchaseOrderCode = purchaseOrderCode;
    }

    @JsonProperty("ImageList")
    public List<String> getImageList() {
        return ImageList;
    }

    public void setImageList(List<String> imageList) {
        ImageList = imageList;
    }
}
